package transform;

import com.sun.xml.internal.ws.developer.SerializationFeature;
import org.apache.commons.lang.SerializationUtils;
import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Serializer;

import java.io.Serializable;
import java.util.Map;

/**
 * @Author:RenPu
 * @Date: 2020/3/19 15:56
 * @Version: 1.0
 * @description:序列化器
 */
public class UserSerializer implements Serializer<User> {

    @Override
    public void configure(Map<String, ?> map, boolean b) {

    }

    @Override
    public byte[] serialize(String s, User user) {

        //使用jdk自带的序列化工具类，进行将对象序列化
        byte[] btye = SerializationUtils.serialize((Serializable) user);
        return btye;
    }

    @Override
    public byte[] serialize(String topic, Headers headers, User data) {
        return new byte[0];
    }

    @Override
    public void close() {

    }
}
